<?
	include("includes/config.php");
	include("includes/login.php");
	include("includes/functions.php");
	if(@$_POST['adauga']){
		$nume = $_POST['nume'];
		$cnp = $_POST['cnp'];
		$ci = $_POST['ci'];
		$localitate = $_POST['localitate'];
		$telefon = $_POST['telefon'];
		$email = $_POST['email'];
		$web = $_POST['web'];
		
		$numar_inmatriculare = numarMasina($_POST['numarInmatriculare']);
		$numar_inmatriculare = strtoupper($numar_inmatriculare);
		$tipmasina = $_POST['tipmasina'];
		$nrkm = $_POST['nrkm'];
		$serievin = $_POST['serievin'];
		$seriemotor = $_POST['seriemotor'];
		$cp = $_POST['cp'];
		$combustibil = $_POST['combustibil'];
		
		mysql_query("insert into parteneri (id_client,nume,cnp,CI,localitate,telefon,email,web,tip_persoana) values(NULL,'$nume','$cnp','$ci','$localitate','$telefon','$email','$web','fizica') ") or die(mysql_error());
		$id_partener = mysql_insert_id();
		mysql_query("insert into parteneri_masini (id_masina,numar_inmatriculare,id_partener,nr_km,serie_caroserie,tip_masina,serie_motor,capacitate_cilindrica,tip_combustibil) values(NULL,'$numar_inmatriculare','$id_partener','$nrkm','$serievin','$tipmasina','$seriemotor','$cp','$combustibil')") or die(mysql_error());
			$id_masina = mysql_insert_id();
		header("location:/comandanoua.php?id_client=".$id_partener."&id_masina=".$id_masina);
	}
	
?>
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="css/style.css" />
	</head>
	<body>
		<div id="header"><h1> <? echo detaliFirma('nume_firma'); ?></h1></div>
		<div id="warper">
			<?
				$resMeniu = mysql_query("select * from meniu");
			?>
			<div id="menu">
				<ul>
					<? while($rowMen = mysql_fetch_array($resMeniu)): ?>
					<li><a href="<?echo $rowMen['link'];?>"><? echo $rowMen['numeLink']; ?></a></li>
					<? endwhile; ?>
				</ul>
			</div>
			<div id="content">
				<div id="contentWrap">
					<h2>Adauga Partener sau Masina</h2>
					<p class="block">
						<a href="/partener_nou_pers_fizica.php" class="buton" > Persoana Fizica </a>&nbsp;
						<a href="/partener_nou_pers_juridica.php" class="buton" > Persoana Juridica </a>&nbsp;
					<p>
					<form action="" method="post">
						<div id="partenerSize">
							<h3>Informatii Partener</h3>
						<p>
							<label>Nume</label>
							<input class="text" type="text" name="nume" value="">
						</p>
					
						<p>
							<label>C.N.P</label>
							<input class="text" type="text" name="cnp" value="">
						</p>
						<p>
							<label>C.I</label>
							<input class="text" type="text" name="ci" value="">
						</p>
						<p>
							<label>Localitate</label>
							<input class="text" type="text" name="localitate" value="">
						</p>
						<p>
							<label>Telefon</label>
							<input class="text" type="text" name="telefon" value="">
						</p>
						<p>
							<label>Email</label>
							<input class="text" type="text" name="email" value="">
						</p>
						<p>
							<label>Web</label>
							<input class="text" type="text" name="web" value="">
						</p>
					</div>
					<div id="masinaSize">
						<h3>Informatii Masina</h3>
						<p>
							<label>Tip Masina</label>
							<input type="text" class="text" name="tipmasina" value="">
						</p>
						<p>
							<label>Numar Inmatriculare </label>
							<input type="text" class="text" name="numarInmatriculare" value="">
						</p>
						<p>
							<label>Numar Km</label>
							<input type="text" class="text" name="nrkm" value="">
						</p>
						<p>
							<label>Serie caroserie</label>
							<input type="text" class="text" name="serievin" value="">
						</p>
						<p>
							<label>Serie Motor</label>
							<input type="text" class="text" name="seriemotor" value="">
						</p>
						<p>
							<label>Capcitate cilindrica</label>
							<input type="text" class="text" name="cp" value="">
						</p>
						<p>
							<label>Tip Combustibil</label>
							<input type="text" class="text" name="combustibil" value="">
						</p>
					</div>
					<div style="clear:both"></div>
						
						
						<p>
							<input class="buton" type="submit" value="Deschide Comanda / Deviz" name="adauga">
						</p>
					</form>
				</div>
			</div>
		</div>
	</body>
</html>